package com.heima.article.listener;

import com.alibaba.fastjson.JSON;
import com.heima.article.service.ApArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.util.Map;

@Component
public class KafkaWmNewsListener {
    @Autowired
    private ApArticleService apArticleService;

    @KafkaListener(topics = "wmNews-topic")
    public void listenerMsg(String msg) throws Exception {
        if (!StringUtils.isEmpty(msg)){
            Map map = JSON.parseObject(msg, Map.class);
            apArticleService.updateEnable(map);
        }
    }
}
